package com.xumingxun.aibox.domain.node;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID;
import com.xumingxun.aibox.context.Context;
import com.xumingxun.aibox.domain.ai.AiHistory;
import com.xumingxun.aibox.domain.var.Var;
import com.xumingxun.aibox.enums.NodeTypeEnum;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.ArrayList;
import java.util.Date;

@Getter
@Setter
public class StartNode extends Node{

    Var questionVar;

    public StartNode(Context context) {
        super(context);
        init();
    }
    @Override
    public void init() {
        this.type = NodeTypeEnum.START;
        this.export = false;
        this.nodeName = "Start Node";

        context.setGlobalVarValue(new Var("global","time","当前时间"), DateUtil.formatDateTime(new Date()));
        context.setGlobalVarValue(new Var("global","history_context","历史聊天记录"), new ArrayList<AiHistory>());

        String uuid=UUID.randomUUID().toString();
        context.setGlobalVarValue(new Var("global","chat_id","对话 ID"),uuid);

        questionVar=new Var(this.nodeName,"question","用户问题");
        this.exportVars.add(questionVar);
    }

    @Override
    public Node execute() {
        return next;
    }

    @Override
    public String getResult() {
        return null;
    }

    public NodeTypeEnum getType() {
        return NodeTypeEnum.START;
    }

}
